<template>
    <el-row :gutter="20">
        <!-- 回到顶部开始 -->
        <el-col :span="6">
            <el-backtop>
                <div style="{
                    height: 100%;
                    width: 100%;
                    background-color: #f2f5f6;
                    box-shadow: 0 0 10px rgba(0,0,0, .12);
                    text-align: center;
                    line-height: 40px;
                    color:#34B8CC;
                    }">Top</div>
            </el-backtop>
            <!-- 回到顶部结束 -->
        </el-col>
        <!-- 时间线开始 -->
        <el-col :span="8" style="margin-top: 40px;margin-bottom: 40px;">
            <div class="block">
                <el-timeline>
                    <el-timeline-item :timestamp="item.time" placement="top" icon="el-icon-more" v-for="item in messages">
                        <el-card>
                            <img :src="item.avatar" style="width: 60px; height:60px; border-radius:50%" />
                            <div><b style="font-size: 14px">{{ item.username }}</b></div>
                            <div style="padding: 10px 0; color: #888">
                                {{ item.content }}
                            </div>
                            <div style="background-color: #34B8CC; padding: 10px" v-if="item.parentMessage">{{
                                item.parentMessage.content }}</div>
                        </el-card>
                    </el-timeline-item>
                </el-timeline>
            </div>

        </el-col>
        <!-- 时间线结束 -->
        <el-col :span="6">
            <div class="grid-content bg-purple"></div>
        </el-col>
    </el-row>
</template>
<script>
import request from "@/utils/request";

export default {
    name: "MessageTimer",
    data() {
        return {
            messages: [],
        }
    },
    created() {
        this.loadMessage();
    },
    methods: {
        loadMessage() {
            let foreignId = 0
            request.get("/message/foreign/" + foreignId).then(res => {
                this.messages = res.data;
            })
        }
    }
}
</script>